package com.shop.controller;

import com.shop.aop.AuthAspect;
import com.shop.entity.Order;
import com.shop.entity.OrderDetails;
import com.shop.model.PageParam;
import com.shop.model.vo.Rsp;
import com.shop.service.MerchantOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("merchant-order")
public class MerchantOrderController {

    @Autowired
    MerchantOrderService merchantOrderService;


    @PostMapping("getOrderListByMerchantId")
    public Rsp getOrderListByMerchantId(@RequestHeader("merchantId")Integer merchantId,@RequestBody PageParam<Order> pageParam)
    {
        return new Rsp(merchantOrderService.getOrderListByMerchantId(merchantId,pageParam)!=null?200:500,"",merchantOrderService.getOrderListByMerchantId(merchantId,pageParam));
    }

    @PostMapping("updateOrderStatus")
    public Rsp updateOrderStatus(@RequestHeader("merchantId")Integer merchantId, @RequestBody Order order)
    {
        System.out.println(order);
        return new Rsp(merchantOrderService.updateOrderStatus(order)>0?200:500,"",null);
    }
    @GetMapping("getTotalInfoMerchantId")
    public Rsp getIndexShowMerchantByMerchantId(@RequestHeader("merchantId")Integer merchantId){
        return new Rsp(merchantOrderService.getTotalSalePriceByMerchantId(merchantId)!=null?200:500,"",merchantOrderService.getTotalSalePriceByMerchantId(merchantId));
    }

}
